<?php

class QueryResult {

	public $title;
	public $dataLegend;
	private $matrix = array();
	private $rowNames = array();
	private $columnNames = array();

	public function __construct($title=null, $dataLegend=null) {
		$this->title 		= $title;
		$this->dataLegend 	= $dataLegend;
	}

	public function getRowNames() {
		return $this->rowNames;
	}

	public function getColumnNames() {
		return $this->columnNames;
	}

	public function getMatrix() {
		return $this->matrix;
	}

	public function setData($rowName, $columnName, $value) {
		if (!isset($this->matrix[$rowName])) {
			$this->matrix[$rowName] = array();
		}

		if (!in_array($rowName, $this->rowNames)) {
			array_push($this->rowNames, $rowName);
		}

		if (!in_array($columnName, $this->columnNames)) {
			array_push($this->columnNames, $columnName);
		}

		$this->matrix[$rowName][$columnName] = $value;
	}

	public function transpose() {

	}


	public function toString() {
		$toReturn = "QueryResult: " . $this->title . "\n";
		for ($i=0; $i<$this->length(); $i++) {
			$toReturn .= $this->sets[$i]->toString();
			$toReturn .= "\n";
			$toReturn .= "\n";
		}
		return $toReturn;
	}

}

?>